<?php
$front = Zend_Controller_Front::getInstance()->getRequest();
$action = "/" . $front->getModuleName() . "/" . $front->getControllerName() ;
?>
<script type="text/javascript" >
function confirmDelete( id, locked ) {
    var accion = 'eliminar';
    if( locked == 'T' ) {
        accion = 'recuperar';
    }
	Sexy.confirm('Esta segur@ que quiere ' + accion + ' este registro?', {onComplete:
		function(returnvalue) {
            if(returnvalue) {
              	Sexy.info('Registro eliminado con exito');
              	location.href= "<?=$action?>/delete/id/" + id;
            } else{
            	return false;
        	}
    	}
	});
}
</script>

<h1>Roles</h1>

<form action="" method="post" >
    <input type="submit" name="Guardar" id="Guardar" value="Guardar" />
    <table class="fullwidth" cellpadding="0" cellspacing="0" border="0">
        <thead>
            <tr>
                <td>Resource</td>
                <td>Permissions</td>
            </tr>
        </thead>

        <tbody>
            <?php foreach ( $this->permissions as $r => $actions ) : ?>
            <tr>
                <td><?=$r?></td>

                <td>
                    <?php foreach ( $actions as $a ) :?>

                    <?php
                    /** Sino existen resource asociados al usuario tira error, entonces generamos un resource vacio */
                    if( !isset( $this->have[strtolower($r)]) ) {
                        $this->have[strtolower($r)] = array();
                    }
                    ?>
                    &nbsp;
                    <span>
                            <input type="checkbox" <?=(in_array( $a, $this->have[strtolower($r)]))?'checked':''?>
                                   name="permission[<?=$r?>-<?=$a?>]"/><?=$a?>
                    </span>&nbsp;&nbsp;
                    <?php endforeach;?>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    <input type="submit" name="Guardar" id="Guardar" value="Guardar" />
</form>

